<?php
include(getabspath("include/sales_orders_settings.php"));

function DisplayMasterTableInfo_sales_orders($params)
{
	$detailtable=$params["detailtable"];
	$keys=$params["keys"];
	global $conn,$strTableName;
	$xt = new Xtempl();
	
	$oldTableName=$strTableName;
	$strTableName="sales_orders";

//$strSQL = "SELECT id,   order_date,   order_no,   account_id,   buyer_id,   currency_id,   shipment_mode_id  FROM sales_orders ";

$sqlHead="SELECT id,   order_date,   order_no,   account_id,   buyer_id,   currency_id,   shipment_mode_id";
$sqlFrom="FROM sales_orders";
$sqlWhere="";
$sqlTail="";

$where="";

if($detailtable=="sales_order_items")
{
		$where.= GetFullFieldName("id")."=".make_db_value("id",$keys[1-1]);
}
if(!$where)
{
	$strTableName=$oldTableName;
	return;
}
	$str = SecuritySQL("Export");
	if(strlen($str))
		$where.=" and ".$str;
	
	$strWhere=whereAdd($sqlWhere,$where);
	if(strlen($strWhere))
		$strWhere=" where ".$strWhere." ";
	$strSQL= $sqlHead.' '.$sqlFrom.$strWhere.$sqlTail;

//	$strSQL=AddWhere($strSQL,$where);

	LogInfo($strSQL);
	$rs=db_query($strSQL,$conn);
	$data=db_fetch_array($rs);
	if(!$data)
	{
		$strTableName=$oldTableName;
		return;
	}
	$keylink="";
	$keylink.="&key1=".htmlspecialchars(rawurlencode(@$data["id"]));
	


//	id - 
			$value="";
				$value = ProcessLargeText(GetData($data,"id", ""),"field=id".$keylink,"",MODE_PRINT);
			$xt->assign("id_mastervalue",$value);

//	order_date - Short Date
			$value="";
				$value = ProcessLargeText(GetData($data,"order_date", "Short Date"),"field=order%5Fdate".$keylink,"",MODE_PRINT);
			$xt->assign("order_date_mastervalue",$value);

//	order_no - 
			$value="";
				$value = ProcessLargeText(GetData($data,"order_no", ""),"field=order%5Fno".$keylink,"",MODE_PRINT);
			$xt->assign("order_no_mastervalue",$value);

//	account_id - 
			$value="";
				$value=DisplayLookupWizard("account_id",$data["account_id"],$data,$keylink,MODE_PRINT);
			$xt->assign("account_id_mastervalue",$value);

//	buyer_id - 
			$value="";
				$value=DisplayLookupWizard("buyer_id",$data["buyer_id"],$data,$keylink,MODE_PRINT);
			$xt->assign("buyer_id_mastervalue",$value);

//	currency_id - 
			$value="";
				$value=DisplayLookupWizard("currency_id",$data["currency_id"],$data,$keylink,MODE_PRINT);
			$xt->assign("currency_id_mastervalue",$value);

//	shipment_mode_id - 
			$value="";
				$value=DisplayLookupWizard("shipment_mode_id",$data["shipment_mode_id"],$data,$keylink,MODE_PRINT);
			$xt->assign("shipment_mode_id_mastervalue",$value);
	$xt->display("sales_orders_masterprint.htm");
	$strTableName=$oldTableName;

}

?>